/*
 * @Author: wuqingchun
 * @Date: 2024-09-23 20:56:37
 * @Description: 
 * @LastEditors: wuqingchun
 * @LastEditTime: 2024-10-02 19:49:22
 */
#include <functional>

#include "chat_errno.h"
#include "../db/chat_db_mysql.h"
#include "chat_server.h"


CChatServer::CChatServer()
{
    m_objNet.setMessageCallback(std::bind(&CChatSession::OnMessage, &m_objSession, _1, _2, _3));
    m_objNet.SetConnectCallback(std::bind(&CChatSession::OnConnect, &m_objSession, _1));
}

CChatServer::~CChatServer()
{
    
}

int32_t CChatServer::Start()
{
    int32_t iErr = CChatDBMysql::GetInstance().Init();
    if (iErr != CHAT_ERR_OK)
    {
        return iErr;
    }

    iErr = m_objSession.Init();
    if (iErr != CHAT_ERR_OK)
    {
        return iErr;
    }

    m_objThread = std::thread(std::bind(&CChatServer::__ThreadTest, this));

    return m_objNet.Start();
}

void CChatServer::__ThreadTest()
{
    
}
